package com.myframework.utils.configutil;

import java.io.InputStream;

import javax.servlet.ServletConfig;

import org.w3c.dom.Document;

import com.myframework.utils.exceptions.WMConfigException;

public class DBConfig {

	/**
	 * Load an WM database configuration file from the given URI
	 * <p/>
	 * If it loads successfully then parse the file using an XML DOM parser, and
	 * initialize all of the internal configuration objects with the parameters
	 * designated in the file.
	 * 
	 * @param stream
	 *          The input stream containing database configuration resource
	 * @param servletConfig
	 *          The ServletConfig to which the logging info will be passed (via
	 *          its context)
	 * @throws WMConfigException
	 *           If the configuration resource is invalid in some way
	 */
	public static void loadConfig(InputStream stream, ServletConfig servletConfig) throws WMConfigException {
		try {
			// Get a DOM for the given input stream, and then process it
			processConfig(DOMUtil.parse(stream), servletConfig);
		} catch (WMConfigException e) {
			throw e;
		} catch (Exception e) {
			throw new WMConfigException(e);
		}
	}
	
	private static void processConfig(Document doc, ServletConfig servletconfig) throws WMConfigException {
		
	}

}
